//custom-tab-bar/index.js
// import {
//     patientTabBarList,
//     doctorTabBarList
// } from '../utils/tab-service'
var app = getApp();
var patientTabBarList = [{
        selectedIconPath: "/static/tabbar/selectedfoodrecord.png",
        iconPath: "/static/tabbar/foodrecord.png",
        pagePath: "/pages/foodrecord/foodrecord",
        text: "食物"
    },
    {
        selectedIconPath: "/static/tabbar/selectedbloodsugar.png",
        iconPath: "/static/tabbar/bloodsugar.png",
        pagePath: "/pages/bloodsugar/bloodsugar",
        text: "血糖"
    },
    {
        selectedIconPath: "/static/tabbar/selectedsportrecord.png",
        iconPath: "/static/tabbar/sportrecord.png",
        pagePath: "/pages/sportrecord/sportrecord",
        text: "运动"
    },
    {
        selectedIconPath: "/static/tabbar/selecteduserinfo.png",
        iconPath: "/static/tabbar/userinfo.png",
        pagePath: "/pages/userinfo/userinfo",
        text: "我的"
    }
];
var doctorTabBarList = [{
        selectedIconPath: "/static/tabbar/selectedhome.png",
        iconPath: "/static/tabbar/home.png",
        pagePath: "/pages/doctor/home/home",
        text: "主页"
    },
    {
        selectedIconPath: "/static/tabbar/selecteduserinfo.png",
        iconPath: "/static/tabbar/userinfo.png",
        pagePath: "/pages/doctor/doctorinfo/doctorinfo",
        text: "我的"
    }
];
Component({

    /**
     * 组件的属性列表
     */
    properties: {

    },

    /**
     * 组件的初始数据
     */
    data: {
        selected: 0,
        // color: "#666666",
        color: "rgba(2,87,52,0.3)",
        // selectedColor: "#FF5F15",
        selectedColor: "#008B2F",
        backgroundColor: "#ffffff",
        borderStyle: "black",
        list: [],

    },
    attached() {
        const role = wx.getStorageSync('role')
        console.log(role)
        if (role == "doctor") {
            // console.log( this.data.doctorTabBarList)
            this.setData({
                list: doctorTabBarList
            })
        } else if (role == "patient") {
            // console.log( this.data.patientTabBarList)
            this.setData({
                list:patientTabBarList
            })
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        switchTab(event) {
            // data为接受到的参数
            const data = event.currentTarget.dataset;
            // 取出参数中的path作为路由跳转的目标地址
            console.log(this.getTabBar())
            console.log(event)
            wx.switchTab({
                url: data.path
            });
        },
    }
})